# U-Boot: ODROID-C1
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=4

pkgname=uboot-odroid-c1
pkgver=2011.03
pkgrel=16
pkgdesc="U-Boot for ODROID-C1"
arch=('armv7h')
url="https://github.com/hardkernel/u-boot"
license=('GPL')
install=$pkgname.install
makedepends=('git' 'bc')
backup=('boot/boot.ini')
_commit=86125f8efd6b3a3fc0839a03e1c0e9507999449d
source=("https://github.com/hardkernel/u-boot/archive/${_commit}.tar.gz"
        'boot.ini'
        '0001-remove-cross-compiling.patch'
        '0002-sd_fusing-tweaks.patch'
        '0003-compiler_gcc-do-not-redefine-__gnu_attributes.patch'
        '0004-compiler-.h-sync-include-linux-compiler-.h-with-Linu.patch'
        '0005-compiler_gcc-prevent-redefining-attributes.patch'
        '0006-compiler-.h-sync-include-linux-compiler-.h-with-Linu.patch'
        '0007-ARM-asm-io.h-use-static-inline.patch'
        '0008-arm-board-use-__weak.patch'
        '0009-add-vframe_provider_s-definition.patch'
        '0010-common-main.c-make-show_boot_progress-__weak.patch'
        '0011-wait_ms-fix.patch')
md5sums=('7f964216ab4577e4272e4d3dff2529d2'
         'a3514e76d2310ed47e45e3c1a287846f'
         '73747be79c5bb654ee58c6f380c57d8a'
         '7601eb51e42e57b53b9d09dad2091f69'
         '14fae8682ce2a257453f7c6ef4af6db3'
         'e17606271ce9cc51f5043b53b54a1132'
         'e6e7ba4c25daf9d6a2c4752861cd38db'
         '80a2585e733fa0ae83facaa0b26c3cd5'
         'f110315cde83e591fda57967ecc7c6d5'
         '420ae0ecf8772c3af3f06ef311f5ad20'
         '2ee3e8fb68a8c7c3b5ac5ba687e4ed41'
         '42319d0ca8043cdfae865e069ebcfd0d'
         'c2ac220ab5c0d7c1bce12e677b40c096')

prepare() {
  cd u-boot-${_commit}

  git apply ../0001-remove-cross-compiling.patch
  git apply ../0002-sd_fusing-tweaks.patch
  git apply ../0003-compiler_gcc-do-not-redefine-__gnu_attributes.patch
  git apply ../0004-compiler-.h-sync-include-linux-compiler-.h-with-Linu.patch
  git apply ../0005-compiler_gcc-prevent-redefining-attributes.patch
  git apply ../0006-compiler-.h-sync-include-linux-compiler-.h-with-Linu.patch
  git apply ../0007-ARM-asm-io.h-use-static-inline.patch
  git apply ../0008-arm-board-use-__weak.patch
  git apply ../0009-add-vframe_provider_s-definition.patch
  git apply ../0010-common-main.c-make-show_boot_progress-__weak.patch
  git apply ../0011-wait_ms-fix.patch
}

build() {
  cd u-boot-${_commit}

  unset CFLAGS CXXFLAGS CPPFLAGS LDFLAGS
  
  make distclean
  make odroidc_config
  make EXTRAVERSION=-${pkgrel}
}

package() {
  cd u-boot-${_commit}/sd_fuse

  mkdir -p "${pkgdir}"/boot
  cp bl1.bin.hardkernel sd_fusing.sh u-boot.bin "${pkgdir}"/boot
  cp "${srcdir}"/boot.ini "${pkgdir}"/boot
}
